

package com.wzl.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;

import javax.servlet.http.HttpServletResponse;

/**
 * @description 返回json结果工具类
 * @date   2021-08-26 下午4:11
 * @author  wzl
 */
@UtilityClass
public class ResUtil {

    @SneakyThrows
    public void jsonResult(HttpServletResponse response, Res res) {
        ObjectMapper objectMapper = new ObjectMapper();
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(objectMapper.writeValueAsString(res));
    }
}
